﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VitCode.Castle.DataAccess;

namespace CRS.Web.UserControls
{
    public partial class GoodsTypeCtl : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                var hql = "Select o.Id,o.Name From GoodsType o";
                var acc = new BaseDataAccess();
                try
                {
                    var list = acc.Session.CreateQuery(hql).List();
                    InnerDdl.Items.Clear();
                    InnerDdl.Items.Add("");
                    foreach (object[] objs in list)
                    {
                        InnerDdl.Items.Add(new ListItem(objs[1].ToString(), objs[0].ToString()));
                    }
                }
                finally
                {
                    acc.CloseSession();
                }
                
            }
        }

        public string ConditionString
        {
            get { return InnerDdl.SelectedItem.Text; }
        }

        
    }
}